package com.home.security.browser.shiro;

import com.home.security.core.enums.LoginTypeEnum;
import org.apache.shiro.authc.UsernamePasswordToken;

/**
 * Description: 重写 UsernamePasswordToken 实现免密码登录
 * Created by 王大宸 on 2020-11-10 23:20
 * Created with IntelliJ IDEA.
 */
public class AuthToken extends UsernamePasswordToken {
    private static final long serialVersionUID = -2564928913725078138L;

    /**
     * 登录类型
     */
    private LoginTypeEnum type;

    /**
     * 登录客户端
     */
    private String client;


    public AuthToken() {
        super();
    }

    /**
     * 免密登录
     *
     * @param username 登录账号
     * @param client   登录客户端
     */
    public AuthToken(String username, String client) {
        super(username, "", false, null);
        this.type = LoginTypeEnum.NO_PASSWORD;
        this.client = client;
    }

    /**
     * 账号密码登录
     *
     * @param username 登录名
     * @param password 登录密码
     * @param client   客户端
     */
    public AuthToken(String username, String password, String client) {
        super(username, password, false, null);
        this.type = LoginTypeEnum.PASSWORD;
        this.client = client;
    }

    public AuthToken(String username, String password, LoginTypeEnum type, String client, boolean rememberMe, String host) {
        super(username, password, rememberMe, host);
        this.type = type;
        this.client = client;
    }

    public LoginTypeEnum getType() {
        return type;
    }

    public void setType(LoginTypeEnum type) {
        this.type = type;
    }

    public String getClient() {
        return client;
    }

    public void setClient(String client) {
        this.client = client;
    }

}
